home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume6 / rpc2 / part04 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  52.5 KB

  1. Subject:  v06i092:  Sun RPC Source (rpc2), Part04/11
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.UUCP
  4.  
  5. Submitted by: cca!SUN.COM!marks (Mark Stein)
  6. Mod.sources: Volume 6, Issue 92
  7. Archive-name: rpc2/Part04
  8.  
  9. [  All I did was verify that the shar files unpacked correctly.  --r$  ]
  10.  
  11. Sun RPC source (part 4 of 11).  This software package contains code
  12. and documentation for Revision 3.0 of the Sun Remote Procedure Call
  13. library.  In addition, a beta version of the XDR/RPC protocol compiler
  14. is included.  Comments about this latest release may be mailed to
  15. sun!rpc or rpc@sun.com.
  16.  
  17. Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  18. unrestricted use provided that this legend is included on all tape
  19. media and as a part of the software program in whole or part.  Users
  20. may copy or modify Sun RPC without charge, but are not authorized to
  21. license or distribute it to anyone else except as part of a product or
  22. program developed by the user.
  23.  
  24. - - - - - - - - - C U T - H E R E - - - - - - - - - - - - - - - - - -
  25. #! /bin/sh
  26. # This is a shell archive, meaning:
  27. # 1. Remove everything above the #! /bin/sh line.
  28. # 2. Save the resulting text in a file.
  29. # 3. Execute the file with /bin/sh (not csh) to create:
  30. #    rpc/doc/rpc.prog.p2
  31. #    rpc/doc/xdr.spec.p2
  32. # This archive created: Mon Jul 14 16:55:08 1986
  33. export PATH; PATH=/bin:/usr/bin:$PATH
  34. for d in rpc rpc/doc rpc/rpclib rpc/tools rpc/toys rpc/rpclib/profiled rpc/rpcgen rpc/rpcgen/test
  35. do
  36.     if test ! -d $d
  37.     then
  38.         echo "shar: Making directory $d"
  39.         mkdir $d
  40.         chmod 755 $d
  41.     fi
  42. done
  43. echo shar: "extracting 'rpc/doc/rpc.prog.p2'" '(33027 characters)'
  44. if test -f 'rpc/doc/rpc.prog.p2'
  45. then
  46.     echo shar: "will not over-write existing file 'rpc/doc/rpc.prog.p2'"
  47. else
  48. sed 's/^X//' << \SHAR_EOF > 'rpc/doc/rpc.prog.p2'
  49. X.LP
  50. XIn order to do an RPC callback,
  51. Xyou need a program number to make the RPC call on.
  52. XSince this will be a dynamically generated program number,
  53. Xit should be in the transient range, 0x40000000 - 0x5fffffff.
  54. XThe routine
  55. X.LW gettransient()
  56. Xreturns a valid program number in the transient range,
  57. Xand registers it with the portmapper.
  58. XIt only talks to the portmapper running on the same machine as the
  59. X.LW gettransient()
  60. Xroutine itself.
  61. XThe call to
  62. X.LW pmap_set()
  63. Xis a test and set operation,
  64. Xin that it indivisibly tests whether a program number
  65. Xhas already been registered,
  66. Xand if it has not, then reserves it.
  67. XOn return, the
  68. X.LW sockp
  69. Xargument will contain a socket that can be used
  70. Xas the argument to an
  71. X.LW svcudp_create()
  72. Xor
  73. X.LW svctcp_create()
  74. Xcall.
  75. X.BS
  76. X.LS no
  77. X#include <stdio.h>
  78. X#include <rpc/rpc.h>
  79. X#include <sys/socket.h>
  80. X.sp.5
  81. Xgettransient(proto, vers, sockp)
  82. X    int proto, vers, *sockp;
  83. X{
  84. X    static int prognum = 0x40000000;
  85. X    int s, len, socktype;
  86. X    struct sockaddr_in addr;
  87. X.sp.5
  88. X    switch(proto) {
  89. X        case IPPROTO_UDP:
  90. X            socktype = SOCK_DGRAM;
  91. X            break;
  92. X        case IPPROTO_TCP:
  93. X            socktype = SOCK_STREAM;
  94. X            break;
  95. X        default:
  96. X            fprintf(stderr, "unknown protocol type\en");
  97. X            return 0;
  98. X    }
  99. X    if (*sockp == RPC_ANYSOCK) {
  100. X        if ((s = socket(AF_INET, socktype, 0)) < 0) {
  101. X            perror("socket");
  102. X            return (0);
  103. X        }
  104. X        *sockp = s;
  105. X    }
  106. X    else
  107. X        s = *sockp;
  108. X    addr.sin_addr.s_addr = 0;
  109. X    addr.sin_family = AF_INET;
  110. X    addr.sin_port = 0;
  111. X    len = sizeof(addr);
  112. X    /*
  113. X     * may be already bound, so don't check for error
  114. X     */
  115. X    bind(s, &addr, len);
  116. X    if (getsockname(s, &addr, &len)< 0) {
  117. X        perror("getsockname");
  118. X        return (0);
  119. X    }
  120. X    while (!pmap_set(prognum++, vers, proto, addr.sin_port))
  121. X        continue;
  122. X    return (prognum-1);
  123. X}
  124. X.Lf
  125. X.BE
  126. XThe following pair of programs illustrate how to use the
  127. X.LW gettransient()
  128. Xroutine.
  129. XThe client makes an RPC call to the server,
  130. Xpassing it a transient program number.
  131. XThen the client waits around to receive a callback
  132. Xfrom the server at that program number.
  133. XThe server registers the program
  134. X.LW EXAMPLEPROG ,
  135. Xso that it can receive the RPC call
  136. Xinforming it of the callback program number.
  137. XThen at some random time (on receiving an
  138. X.LW ALRM
  139. Xsignal in this example), it sends a callback RPC call,
  140. Xusing the program number it received earlier.
  141. X.BS
  142. X.LS no
  143. X/*
  144. X * client
  145. X */
  146. X#include <stdio.h>
  147. X#include <rpc/rpc.h>
  148. X.sp.5
  149. Xint callback();
  150. Xchar hostname[256];
  151. X.sp.5
  152. Xmain(argc, argv)
  153. X    char **argv;
  154. X{
  155. X    int x, ans, s;
  156. X    SVCXPRT *xprt;
  157. X.sp.5
  158. X    gethostname(hostname, sizeof(hostname));
  159. X    s = RPC_ANYSOCK;
  160. X    x = gettransient(IPPROTO_UDP, 1, &s);
  161. X    fprintf(stderr, "client gets prognum %d\en", x);
  162. X    if ((xprt = svcudp_create(s)) == NULL) {
  163. X      fprintf(stderr, "rpc_server: svcudp_create\en");
  164. X        exit(1);
  165. X    }
  166. X    /* protocol is 0 - gettransient() does registering
  167. X     */
  168. X    (void)svc_register(xprt, x, 1, callback, 0);
  169. X    ans = callrpc(hostname, EXAMPLEPROG, EXAMPLEVERS,
  170. X        EXAMPLEPROC_CALLBACK, xdr_int, &x, xdr_void, 0);
  171. X    if (ans != RPC_SUCCESS) {
  172. X        fprintf(stderr, "call: ");
  173. X        clnt_perrno(ans);
  174. X        fprintf(stderr, "\en");
  175. X    }
  176. X    svc_run();
  177. X    fprintf(stderr, "Error: svc_run shouldn't return\en");
  178. X}
  179. X.sp.5
  180. Xcallback(rqstp, transp)
  181. X    register struct svc_req *rqstp;
  182. X    register SVCXPRT *transp;
  183. X{
  184. X    switch (rqstp->rq_proc) {
  185. X        case 0:
  186. X            if (!svc_sendreply(transp, xdr_void, 0)) {
  187. X                fprintf(stderr, "err: rusersd\en");
  188. X                exit(1);
  189. X            }
  190. X            exit(0);
  191. X        case 1:
  192. X            if (!svc_getargs(transp, xdr_void, 0)) {
  193. X                svcerr_decode(transp);
  194. X                exit(1);
  195. X            }
  196. X            fprintf(stderr, "client got callback\en");
  197. X            if (!svc_sendreply(transp, xdr_void, 0)) {
  198. X                fprintf(stderr, "err: rusersd");
  199. X                exit(1);
  200. X            }
  201. X    }
  202. X}
  203. X.sp.5
  204. X/*
  205. X * server
  206. X */
  207. X#include <stdio.h>
  208. X#include <rpc/rpc.h>
  209. X#include <sys/signal.h>
  210. X.sp.5
  211. Xchar *getnewprog();
  212. Xchar hostname[256];
  213. Xint docallback();
  214. Xint pnum;        /* program number for callback routine */
  215. X.sp.5
  216. Xmain(argc, argv)
  217. X    char **argv;
  218. X{
  219. X    gethostname(hostname, sizeof(hostname));
  220. X    registerrpc(EXAMPLEPROG, EXAMPLEVERS,
  221. X      EXAMPLEPROC_CALLBACK, getnewprog, xdr_int, xdr_void);
  222. X    fprintf(stderr, "server going into svc_run\en");
  223. X    signal(SIGALRM, docallback);
  224. X    alarm(10);
  225. X    svc_run();
  226. X    fprintf(stderr, "Error: svc_run shouldn't return\en");
  227. X}
  228. X.sp.5
  229. Xchar *
  230. Xgetnewprog(pnump)
  231. X    char *pnump;
  232. X{
  233. X    pnum = *(int *)pnump;
  234. X    return NULL;
  235. X}
  236. X.sp.5
  237. Xdocallback()
  238. X{
  239. X    int ans;
  240. X.sp.5
  241. X    ans = callrpc(hostname, pnum, 1, 1, xdr_void, 0,
  242. X        xdr_void, 0);
  243. X    if (ans != 0) {
  244. X        fprintf(stderr, "server: ");
  245. X        clnt_perrno(ans);
  246. X        fprintf(stderr, "\en");
  247. X    }
  248. X}
  249. X.Lf
  250. X.BE
  251. X.SH
  252. XAppendix A: Synopsis of RPC Routines
  253. X.SH
  254. Xauth_destroy()
  255. X.LP
  256. X.BS
  257. X.LS
  258. Xvoid
  259. Xauth_destroy(auth)
  260. X    AUTH *auth;
  261. X.Lf
  262. X.BE
  263. XA macro that destroys the authentication information associated with
  264. X.LW auth .
  265. XDestruction usually involves deallocation
  266. Xof private data structures.  The use of
  267. X.LW auth
  268. Xis undefined after calling
  269. X.LW auth_destroy() .
  270. X.SH
  271. Xauthnone_create()
  272. X.LP
  273. X.BS
  274. X.LS
  275. XAUTH *
  276. Xauthnone_create()
  277. X.Lf
  278. X.BE
  279. XCreates and returns an RPC authentication handle that passes no
  280. Xusable authentication information with each remote procedure call.
  281. X.SH
  282. Xauthunix_create()
  283. X.LP
  284. X.BS
  285. X.LS
  286. XAUTH *
  287. Xauthunix_create(host, uid, gid, len, aup_gids)
  288. X    char *host;
  289. X    int uid, gid, len, *aup_gids;
  290. X.Lf
  291. X.BE
  292. XCreates and returns an RPC authentication handle that contains
  293. X.UX
  294. Xauthentication information.
  295. XThe parameter
  296. X.LW host
  297. Xis the name of the machine on which the information was created;
  298. X.LW uid
  299. Xis the user's user ID;
  300. X.LW gid
  301. Xis the user's current group ID;
  302. X.LW len
  303. Xand
  304. X.LW aup_gids
  305. Xrefer to a counted array of groups to which the user belongs.
  306. XIt is easy to impersonate a user.
  307. X.SH
  308. Xauthunix_create\%_default()
  309. X.LP
  310. X.BS
  311. X.LS
  312. XAUTH *
  313. Xauthunix_create_default()
  314. X.Lf
  315. X.BE
  316. XCalls
  317. X.LW authunix_create()
  318. Xwith the appropriate parameters.
  319. X.SH
  320. Xcallrpc()
  321. X.LP
  322. X.BS
  323. X.LS
  324. Xcallrpc(host,prognum,versnum,procnum,inproc,in,outproc,out)
  325. X    char *host;
  326. X    u_long prognum, versnum, procnum;
  327. X    char *in, *out;
  328. X    xdrproc_t inproc, outproc;
  329. X.Lf
  330. X.BE
  331. XCalls the remote procedure associated with
  332. X.LW prognum ,
  333. X.LW versnum ,
  334. Xand
  335. X.LW procnum
  336. Xon the machine,
  337. X.LW host .
  338. XThe parameter
  339. X.LW in
  340. Xis the address of the procedure's argument(s), and
  341. X.LW out
  342. Xis the address of where to place the result(s);
  343. X.LW inproc
  344. Xis used to encode the procedure's parameters, and
  345. X.LW outproc
  346. Xis used to decode the procedure's results.
  347. XThis routine returns zero if it succeeds, or the value of
  348. X.LW "enum clnt_stat"
  349. Xcast to an integer if it fails.
  350. XThe routine
  351. X.LW clnt_perrno()
  352. Xis handy for translating failure statuses into messages.
  353. XWarning: calling remote procedures with this routine
  354. Xuses UDP/IP as a transport; see
  355. X.LW clntudp_create()
  356. Xfor restrictions.
  357. X.SH
  358. Xclnt_broadcast()
  359. X.LP
  360. X.BS
  361. X.LS
  362. Xenum clnt_stat
  363. Xclnt_broadcast(prognum, versnum, procnum,
  364. X  inproc, in, outproc, out, eachresult)
  365. X    u_long prognum, versnum, procnum;
  366. X    char *in, *out;
  367. X    xdrproc_t inproc, outproc;
  368. X    resultproc_t eachresult;
  369. X.Lf
  370. X.BE
  371. XLike
  372. X.LW callrpc() ,
  373. Xexcept the call message is broadcast to all locally connected broadcast nets.
  374. XEach time it receives a response, this routine calls
  375. X.LW eachresult() ,
  376. Xwhose form is
  377. X.BS
  378. X.LS
  379. X    eachresult(out, addr)
  380. X        char *out;
  381. X        struct sockaddr_in *addr;
  382. X.Lf
  383. X.BE
  384. Xwhere
  385. X.LW out
  386. Xis the same as
  387. X.LW out
  388. Xpassed to
  389. X.LW clnt_broadcast() ,
  390. Xexcept that the remote procedure's output is decoded there;
  391. X.LW addr
  392. Xpoints to the address of the machine that sent the results.  If
  393. X.LW eachresult()
  394. Xreturns zero,
  395. X.LW clnt_broadcast()
  396. Xwaits for more replies;
  397. Xotherwise it returns with appropriate status.
  398. X.SH
  399. Xclnt_call()
  400. X.LP
  401. X.BS
  402. X.LS
  403. Xenum clnt_stat
  404. Xclnt_call(clnt, procnum, inproc, in, outproc, out, tout)
  405. X    CLIENT *clnt; long procnum;
  406. X    xdrproc_t inproc, outproc;
  407. X    char *in, *out;
  408. X    struct timeval tout;
  409. X.Lf
  410. X.BE
  411. XA macro that calls the remote procedure
  412. X.LW procnum
  413. Xassociated with the client handle,
  414. X.LW clnt ,
  415. Xwhich is obtained with an RPC client creation routine such as
  416. X.LW clntudp_create() .
  417. XThe parameter
  418. X.LW in
  419. Xis the address of the procedure's argument(s), and
  420. X.LW out
  421. Xis the address of where to place the result(s);
  422. X.LW inproc
  423. Xis used to encode the procedure's parameters, and
  424. X.LW outproc
  425. Xis used to decode the procedure's results;
  426. X.LW tout
  427. Xis the time allowed for results to come back.
  428. X.SH
  429. Xclnt_destroy()
  430. X.LP
  431. X.BS
  432. X.LS
  433. Xclnt_destroy(clnt)
  434. X    CLIENT *clnt;
  435. X.Lf
  436. X.BE
  437. XA macro that destroys the client's RPC handle.
  438. XDestruction usually involves deallocation
  439. Xof private data structures, including
  440. X.LW clnt
  441. Xitself.  Use of
  442. X.LW clnt
  443. Xis undefined after calling
  444. X.LW clnt_destroy() .
  445. XIt is the user's responsibility to close sockets associated with
  446. X.LW clnt .
  447. X.SH
  448. Xclnt_freeres()
  449. X.LP
  450. X.BS
  451. X.LS
  452. Xclnt_freeres(clnt, outproc, out)
  453. X    CLIENT *clnt;
  454. X    xdrproc_t outproc;
  455. X    char *out;
  456. X.Lf
  457. X.BE
  458. XA macro that frees any data allocated by the RPC/XDR system
  459. Xwhen it decoded the results of an RPC call.
  460. XThe parameter
  461. X.LW out
  462. Xis the address of the results, and
  463. X.LW outproc
  464. Xis the XDR routine describing the results in simple primitives.
  465. XThis routine returns one if the results were successfully freed,
  466. Xand zero otherwise.
  467. X.SH
  468. Xclnt_geterr()
  469. X.LP
  470. X.BS
  471. X.LS
  472. Xvoid
  473. Xclnt_geterr(clnt, errp)
  474. X    CLIENT *clnt;
  475. X    struct rpc_err *errp;
  476. X.Lf
  477. X.BE
  478. XA macro that copies the error structure out of the client handle
  479. Xto the structure at address
  480. X.LW errp .
  481. X.SH
  482. Xclnt_pcreateerror()
  483. X.LP
  484. X.BS
  485. X.LS
  486. Xvoid
  487. Xclnt_pcreateerror(s)
  488. X    char *s;
  489. X.Lf
  490. X.BE
  491. XPrints a message to standard error indicating
  492. Xwhy a client RPC handle could not be created.
  493. XThe message is prepended with string
  494. X.LW s
  495. Xand a colon.
  496. XUsed after a
  497. X.LW clntraw_create() ,
  498. X.LW clnttcp_create() ,
  499. Xor
  500. X.LW clntudp_create()
  501. Xcall.
  502. X.SH
  503. Xclnt_perrno()
  504. X.LP
  505. X.BS
  506. X.LS
  507. Xvoid
  508. Xclnt_perrno(stat)
  509. X    enum clnt_stat stat;
  510. X.Lf
  511. X.BE
  512. XPrints a message to standard error corresponding
  513. Xto the condition indicated by
  514. X.LW stat .
  515. XUsed after
  516. X.LW callrpc() .
  517. X.SH
  518. Xclnt_perror()
  519. X.LP
  520. X.BS
  521. X.LS
  522. Xclnt_perror(clnt, s)
  523. X    CLIENT *clnt;
  524. X    char *s;
  525. X.Lf
  526. X.BE
  527. XPrints a message to standard error indicating why an RPC call failed;
  528. X.LW clnt
  529. Xis the handle used to do the call.
  530. XThe message is prepended with string
  531. X.LW s
  532. Xand a colon.
  533. XUsed after
  534. X.LW clnt_call() .
  535. X.SH
  536. Xclntraw_create()
  537. X.LP
  538. X.BS
  539. X.LS
  540. XCLIENT *
  541. Xclntraw_create(prognum, versnum)
  542. X    u_long prognum, versnum;
  543. X.Lf
  544. X.BE
  545. XThis routine creates a toy RPC client for the remote program
  546. X.LW prognum ,
  547. Xversion
  548. X.LW versnum .
  549. XThe transport used to pass messages to the service
  550. Xis actually a buffer within the process's address space,
  551. Xso the corresponding RPC server should live in the same address space; see
  552. X.LW svcraw_create() .
  553. XThis allows simulation of RPC and acquisition of RPC overheads,
  554. Xsuch as round trip times, without any kernel interference.
  555. XThis routine returns
  556. X.LW NULL
  557. Xif it fails.
  558. X.SH
  559. Xclnttcp_create()
  560. X.LP
  561. X.BS
  562. X.LS
  563. XCLIENT *
  564. Xclnttcp_create(addr,prognum,versnum,sockp,sendsz,recvsz)
  565. X    struct sockaddr_in *addr;
  566. X    u_long prognum, versnum;
  567. X    int *sockp;
  568. X    u_int sendsz, recvsz;
  569. X.Lf
  570. X.BE
  571. XThis routine creates an RPC client for the remote program
  572. X.LW prognum ,
  573. Xversion
  574. X.LW versnum ;
  575. Xthe client uses TCP/IP as a transport.
  576. XThe remote program is located at Internet address
  577. X.LW *addr .
  578. XIf
  579. X.LW addr->sin_port
  580. Xis zero, then it is set to the actual port that the remote
  581. Xprogram is listening on (the remote
  582. X.I portmap
  583. Xservice is consulted for this information).
  584. XThe parameter
  585. X.LW *sockp
  586. Xis a socket; if it is
  587. X.LW RPC_ANYSOCK ,
  588. Xthen this routine opens a new one and sets
  589. X.LW *sockp .
  590. XSince TCP-based RPC uses buffered I/O, the user may specify
  591. Xthe size of the send and receive buffers with the parameters
  592. X.LW sendsz
  593. Xand
  594. X.LW recvsz ;
  595. Xvalues of zero choose suitable defaults.
  596. XThis routine returns
  597. X.LW NULL
  598. Xif it fails.
  599. X.SH
  600. Xclntudp_create()
  601. X.LP
  602. X.BS
  603. X.LS
  604. XCLIENT *
  605. Xclntudp_create(addr, prognum, versnum, wait, sockp)
  606. X    struct sockaddr_in *addr;
  607. X    u_long prognum, versnum;
  608. X    struct timeval wait;
  609. X    int *sockp;
  610. X.Lf
  611. X.BE
  612. XThis routine creates an RPC client for the remote program
  613. X.LW prognum ,
  614. Xversion
  615. X.LW versnum ;
  616. Xthe client uses use UDP/IP as a transport.
  617. XThe remote program is located at Internet address
  618. X.LW *addr .
  619. XIf
  620. X.LW addr->sin_port
  621. Xis zero, then it is set to actual port that the remote
  622. Xprogram is listening on (the remote
  623. X.I portmap
  624. Xservice is consulted for this information).
  625. XThe parameter
  626. X.LW *sockp
  627. Xis a socket; if it is
  628. X.LW RPC_ANYSOCK ,
  629. Xthen this routine opens a new one and sets
  630. X.LW *sockp .
  631. XThe UDP transport resends the call message in intervals of
  632. X.LW wait
  633. Xtime until a response is received or until the call times out.
  634. XThe total time for the call to time out is specified by
  635. X.LW clnt_call() .
  636. XWarning: since UDP-based RPC messages can only hold up to 8 Kbytes
  637. Xof encoded data, this transport cannot be used for procedures
  638. Xthat take large arguments or return huge results.
  639. X.SH
  640. Xget_myaddress()
  641. X.LP
  642. X.BS
  643. X.LS
  644. Xvoid
  645. Xget_myaddress(addr)
  646. X    struct sockaddr_in *addr;
  647. X.Lf
  648. X.BE
  649. XStuffs the machine's IP address into
  650. X.LW *addr ,
  651. Xwithout consulting the library routines that deal with
  652. X.I /etc/hosts .
  653. XThe port number is always set to
  654. X.LW htons(PMAPPORT) .
  655. X.SH
  656. Xpmap_getmaps()
  657. X.LP
  658. X.BS
  659. X.LS
  660. Xstruct pmaplist *
  661. Xpmap_getmaps(addr)
  662. X    struct sockaddr_in *addr;
  663. X.Lf
  664. X.BE
  665. XA user interface to the
  666. X.I portmap
  667. Xservice, which returns a list of the current RPC program-to-port mappings
  668. Xon the host located at IP address
  669. X.LW *addr .
  670. XThis routine can return
  671. X.LW NULL .
  672. XThe command
  673. X.LW "rpcinfo -p"
  674. Xuses this routine.
  675. X.SH
  676. Xpmap_getport()
  677. X.LP
  678. X.BS
  679. X.LS
  680. Xu_short
  681. Xpmap_getport(addr, prognum, versnum, protocol)
  682. X    struct sockaddr_in *addr;
  683. X    u_long prognum, versnum, protocol;
  684. X.Lf
  685. X.BE
  686. XA user interface to the
  687. X.I portmap
  688. Xservice, which returns the port number
  689. Xon which waits a service that supports program number
  690. X.LW prognum ,
  691. Xversion
  692. X.LW versnum ,
  693. Xand speaks the transport protocol associated with protocol.
  694. XA return value of zero means that the mapping does not exist or that
  695. Xthe RPC system failured to contact the remote
  696. X.I portmap
  697. Xservice.  In the latter case, the global variable
  698. X.LW rpc_createerr
  699. Xcontains the RPC status.
  700. X.SH
  701. Xpmap_rmtcall()
  702. X.LP
  703. X.BS
  704. X.LS
  705. Xenum clnt_stat
  706. Xpmap_rmtcall(addr, prognum, versnum, procnum,
  707. X  inproc, in, outproc, out, tout, portp)
  708. X    struct sockaddr_in *addr;
  709. X    u_long prognum, versnum, procnum;
  710. X    char *in, *out;
  711. X    xdrproc_t inproc, outproc;
  712. X    struct timeval tout;
  713. X    u_long *portp;
  714. X.Lf
  715. X.BE
  716. XA user interface to the
  717. X.I portmap
  718. Xservice, which instructs
  719. X.I portmap
  720. Xon the host at IP address
  721. X.LW *addr
  722. Xto make an RPC call on your behalf to a procedure on that host.
  723. XThe parameter
  724. X.LW *portp
  725. Xwill be modified to the program's port number if the procedure succeeds.
  726. XThe definitions of other parameters are discussed in
  727. X.LW callrpc()
  728. Xand
  729. X.LW clnt_call() .
  730. XThis procedure should be used for a ``ping'' and nothing else.
  731. XSee also
  732. X.LW clnt_broadcast() .
  733. X.SH
  734. Xpmap_set()
  735. X.LP
  736. X.BS
  737. X.LS
  738. Xpmap_set(prognum, versnum, protocol, port)
  739. X    u_long prognum, versnum, protocol;
  740. X    u_short port;
  741. X.Lf
  742. X.BE
  743. XA user interface to the
  744. X.I portmap
  745. Xservice, which establishes a mapping between the triple
  746. X.LW [prognum,versnum,protocol]
  747. Xand
  748. X.LW port
  749. Xon the machine's
  750. X.I portmap
  751. Xservice.  The value of protocol is most likely
  752. X.LW IPPROTO_UDP
  753. Xor
  754. X.LW IPPROTO_TCP .
  755. XThis routine returns one if it succeeds, zero otherwise.
  756. XAutomatically done by
  757. X.LW svc_register() .
  758. X.SH
  759. Xpmap_unset()
  760. X.LP
  761. X.BS
  762. X.LS
  763. Xpmap_unset(prognum, versnum)
  764. X    u_long prognum, versnum;
  765. X.Lf
  766. X.BE
  767. XA user interface to the
  768. X.I portmap
  769. Xservice, which destroys all mappings between the triple
  770. X.LW [prognum,versnum,*]
  771. Xand
  772. X.LW ports
  773. Xon the machine's
  774. X.I portmap
  775. Xservice.
  776. XThis routine returns one if it succeeds, zero otherwise.
  777. X.SH
  778. Xregisterrpc()
  779. X.LP
  780. X.BS
  781. X.LS
  782. Xregisterrpc(prognum,versnum,procnum,procname,inproc,outproc)
  783. X    u_long prognum, versnum, procnum;
  784. X    char *(*procname)();
  785. X    xdrproc_t inproc, outproc;
  786. X.Lf
  787. X.BE
  788. XRegisters procedure
  789. X.LW procname
  790. Xwith the RPC service package.  If a request arrives for program
  791. X.LW prognum ,
  792. Xversion
  793. X.LW versnum ,
  794. Xand procedure
  795. X.LW procnum ,
  796. X.LW procname
  797. Xis called with a pointer to its parameter(s);
  798. X.LW progname
  799. Xshould return a pointer to its static result(s);
  800. X.LW inproc
  801. Xis used to decode the parameters while
  802. X.LW outproc
  803. Xis used to encode the results.
  804. XThis routine returns zero if the registration succeeded, \-1 otherwise.
  805. XWarning: remote procedures registered in this form
  806. Xare accessed using the UDP/IP transport; see
  807. X.LW svcudp_create()
  808. Xfor restrictions.
  809. X.SH
  810. Xrpc_createerr
  811. X.LP
  812. X.BS
  813. X.LS
  814. Xstruct rpc_createerr    rpc_createerr;
  815. X.Lf
  816. X.BE
  817. XA global variable whose value is set by any RPC client creation routine
  818. Xthat does not succeed.  Use the routine
  819. X.LW clnt_pcreateerror()
  820. Xto print the reason why.
  821. X.SH
  822. Xsvc_destroy()
  823. X.LP
  824. X.BS
  825. X.LS
  826. Xsvc_destroy(xprt)
  827. X    SVCXPRT *xprt;
  828. X.Lf
  829. X.BE
  830. XA macro that destroys the RPC service transport handle,
  831. X.LW xprt .
  832. XDestruction usually involves deallocation
  833. Xof private data structures, including
  834. X.LW xprt
  835. Xitself.  Use of
  836. X.LW xprt
  837. Xis undefined after calling this routine.
  838. X.SH
  839. Xsvc_fds
  840. X.LP
  841. X.BS
  842. X.LS
  843. Xint    svc_fds;
  844. X.Lf
  845. X.BE
  846. XA global variable reflecting the RPC service side's
  847. Xread file descriptor bit mask; it is suitable as a parameter to the
  848. X.LW select()
  849. Xsystem call.  This is only of interest
  850. Xif a service implementor does not call
  851. X.LW svc_run() ,
  852. Xbut rather does his own asynchronous event processing.
  853. XThis variable is read-only (do not pass its address to
  854. X.LW select() !),
  855. Xyet it may change after calls to
  856. X.LW svc_getreq()
  857. Xor any creation routines.
  858. X.SH
  859. Xsvc_freeargs()
  860. X.LP
  861. X.BS
  862. X.LS
  863. Xsvc_freeargs(xprt, inproc, in)
  864. X    SVCXPRT *xprt;
  865. X    xdrproc_t inproc;
  866. X    char *in;
  867. X.Lf
  868. X.BE
  869. XA macro that frees any data allocated by the RPC/XDR system
  870. Xwhen it decoded the arguments to a service procedure using
  871. X.LW svc_getargs() .
  872. XThis routine returns one if the results were successfully freed,
  873. Xand zero otherwise.
  874. X.SH
  875. Xsvc_getargs()
  876. X.LP
  877. X.BS
  878. X.LS
  879. Xsvc_getargs(xprt, inproc, in)
  880. X    SVCXPRT *xprt;
  881. X    xdrproc_t inproc;
  882. X    char *in;
  883. X.Lf
  884. X.BE
  885. XA macro that decodes the arguments of an RPC request
  886. Xassociated with the RPC service transport handle,
  887. X.LW xprt .
  888. XThe parameter
  889. X.LW in
  890. Xis the address where the arguments will be placed;
  891. X.LW inproc
  892. Xis the XDR routine used to decode the arguments.
  893. XThis routine returns one if decoding succeeds, and zero otherwise.
  894. X.SH
  895. Xsvc_getcaller()
  896. X.LP
  897. X.BS
  898. X.LS
  899. Xstruct sockaddr_in
  900. Xsvc_getcaller(xprt)
  901. X    SVCXPRT *xprt;
  902. X.Lf
  903. X.BE
  904. XThe approved way of getting the network address of the caller
  905. Xof a procedure associated with the RPC service transport handle,
  906. X.LW xprt .
  907. X.SH
  908. Xsvc_getreq()
  909. X.LP
  910. X.BS
  911. X.LS
  912. Xsvc_getreq(rdfds)
  913. X    int rdfds;
  914. X.Lf
  915. X.BE
  916. XThis routine is only of interest if a service implementor does not call
  917. X.LW svc_run() ,
  918. Xbut instead implements custom asynchronous event processing.
  919. XIt is called when the
  920. X.LW select()
  921. Xsystem call has determined that an RPC request
  922. Xhas arrived on some RPC socket(s);
  923. X.LW rdfds
  924. Xis the resultant read file descriptor bit mask.
  925. XThe routine returns when all sockets associated with the value of
  926. X.LW rdfds
  927. Xhave been serviced.
  928. X.SH
  929. Xsvc_register()
  930. X.LP
  931. X.BS
  932. X.LS
  933. Xsvc_register(xprt, prognum, versnum, dispatch, protocol)
  934. X    SVCXPRT *xprt;
  935. X    u_long prognum, versnum;
  936. X    void (*dispatch)();
  937. X    u_long protocol;
  938. X.Lf
  939. X.BE
  940. XAssociates
  941. X.LW prognum
  942. Xand
  943. X.LW versnum
  944. Xwith the service dispatch procedure,
  945. X.LW dispatch() .
  946. XIf
  947. X.LW protocol
  948. Xis zero, the service is not registered with the
  949. X.I portmap
  950. Xservice.  If
  951. X.LW protocol
  952. Xis non-zero, then a mapping of the triple
  953. X.LW [prognum,versnum,protocol]
  954. Xto
  955. X.LW xprt->xp_port
  956. Xis established with the local
  957. X.I portmap
  958. Xservice (generally
  959. X.LW protocol
  960. Xis zero,
  961. X.LW IPPROTO_UDP
  962. Xor
  963. X.LW IPPROTO_TCP ).
  964. XThe procedure
  965. X.LW dispatch()
  966. Xhas the following form:
  967. X.BS
  968. X.LS
  969. X    dispatch(request, xprt)
  970. X        struct svc_req *request;
  971. X        SVCXPRT *xprt;
  972. X.Lf
  973. X.BE
  974. XThe
  975. X.LW svc_register()
  976. Xroutine returns one if it succeeds, and zero otherwise.
  977. X.SH
  978. Xsvc_run()
  979. X.LP
  980. X.BS
  981. X.LS
  982. Xsvc_run()
  983. X.Lf
  984. X.BE
  985. XThis routine never returns.  It waits for RPC requests to arrive,
  986. Xand calls the appropriate service procedure using
  987. X.LW svc_getreq()
  988. Xwhen one arrives.  This procedure is usually waiting for a
  989. X.LW select()
  990. Xsystem call to return.
  991. X.SH
  992. Xsvc_sendreply()
  993. X.LP
  994. X.BS
  995. X.LS
  996. Xsvc_sendreply(xprt, outproc, out)
  997. X    SVCXPRT *xprt;
  998. X    xdrproc_t outproc;
  999. X    char *out;
  1000. X.Lf
  1001. X.BE
  1002. XCalled by an RPC service's dispatch routine
  1003. Xto send the results of a remote procedure call.
  1004. XThe parameter
  1005. X.LW xprt
  1006. Xis the caller's associated transport handle;
  1007. X.LW outproc
  1008. Xis the XDR routine which is used to encode the results; and
  1009. X.LW out
  1010. Xis the address of the results.
  1011. XThis routine returns one if it succeeds, zero otherwise.
  1012. X.SH
  1013. Xsvc_unregister()
  1014. X.LP
  1015. X.BS
  1016. X.LS
  1017. Xvoid
  1018. Xsvc_unregister(prognum, versnum)
  1019. X    u_long prognum, versnum;
  1020. X.Lf
  1021. X.BE
  1022. XRemoves all mapping of the double
  1023. X.LW [prognum,versnum]
  1024. Xto dispatch routines, and of the triple
  1025. X.LW [prognum,versnum,*]
  1026. Xto port number.
  1027. X.SH
  1028. Xsvcerr_auth()
  1029. X.LP
  1030. X.BS
  1031. X.LS
  1032. Xvoid
  1033. Xsvcerr_auth(xprt, why)
  1034. X    SVCXPRT *xprt;
  1035. X    enum auth_stat why;
  1036. X.Lf
  1037. X.BE
  1038. XCalled by a service dispatch routine that refuses to perform
  1039. Xa remote procedure call due to an authentication error.
  1040. X.SH
  1041. Xsvcerr_decode()
  1042. X.LP
  1043. X.BS
  1044. X.LS
  1045. Xvoid
  1046. Xsvcerr_decode(xprt)
  1047. X    SVCXPRT *xprt;
  1048. X.Lf
  1049. X.BE
  1050. XCalled by a service dispatch routine that can't successfully
  1051. Xdecode its parameters.  See also
  1052. X.LW svc_getargs() .
  1053. X.SH
  1054. Xsvcerr_noproc()
  1055. X.LP
  1056. X.BS
  1057. X.LS
  1058. Xvoid
  1059. Xsvcerr_noproc(xprt)
  1060. X    SVCXPRT *xprt;
  1061. X.Lf
  1062. X.BE
  1063. XCalled by a service dispatch routine that doesn't implement
  1064. Xthe desired procedure number the caller request.
  1065. X.SH
  1066. Xsvcerr_noprog()
  1067. X.LP
  1068. X.BS
  1069. X.LS
  1070. Xvoid
  1071. Xsvcerr_noprog(xprt)
  1072. X    SVCXPRT *xprt;
  1073. X.Lf
  1074. X.BE
  1075. XCalled when the desired program is not registered with the RPC package.
  1076. XService implementors usually don't need this routine.
  1077. X.SH
  1078. Xsvcerr_progvers()
  1079. X.LP
  1080. X.BS
  1081. X.LS
  1082. Xvoid
  1083. Xsvcerr_progvers(xprt)
  1084. X    SVCXPRT *xprt;
  1085. X.Lf
  1086. X.BE
  1087. XCalled when the desired version of a program is not registered
  1088. Xwith the RPC package.
  1089. XService implementors usually don't need this routine.
  1090. X.SH
  1091. Xsvcerr_systemerr()
  1092. X.LP
  1093. X.BS
  1094. X.LS
  1095. Xvoid
  1096. Xsvcerr_systemerr(xprt)
  1097. X    SVCXPRT *xprt;
  1098. X.Lf
  1099. X.BE
  1100. XCalled by a service dispatch routine when it detects a system error
  1101. Xnot covered by any particular protocol.
  1102. XFor example, if a service can no longer allocate storage,
  1103. Xit may call this routine.
  1104. X.SH
  1105. Xsvcerr_weakauth()
  1106. X.LP
  1107. X.BS
  1108. X.LS
  1109. Xvoid
  1110. Xsvcerr_weakauth(xprt)
  1111. X    SVCXPRT *xprt;
  1112. X.Lf
  1113. X.BE
  1114. XCalled by a service dispatch routine that refuses to perform
  1115. Xa remote procedure call due to insufficient (but correct)
  1116. Xauthentication parameters.  The routine calls
  1117. X.LW svcerr_auth(xprt,AUTH_TOOWEAK) .
  1118. X.SH
  1119. Xsvcraw_create()
  1120. X.LP
  1121. X.BS
  1122. X.LS
  1123. XSVCXPRT *
  1124. Xsvcraw_create()
  1125. X.Lf
  1126. X.BE
  1127. XThis routine creates a toy RPC service transport,
  1128. Xto which it returns a pointer.  The transport
  1129. Xis really a buffer within the process's address space,
  1130. Xso the corresponding RPC client should live in the same address space; see
  1131. X.LW clntraw_create() .
  1132. XThis routine allows simulation of RPC and acquisition of RPC overheads
  1133. X(such as round trip times), without any kernel interference.
  1134. XThis routine returns
  1135. X.LW NULL
  1136. Xif it fails.
  1137. X.SH
  1138. Xsvctcp_create()
  1139. X.LP
  1140. X.BS
  1141. X.LS
  1142. XSVCXPRT *
  1143. Xsvctcp_create(sock, send_buf_size, recv_buf_size)
  1144. X    int sock;
  1145. X    u_int send_buf_size, recv_buf_size;
  1146. X.Lf
  1147. X.BE
  1148. XThis routine creates a TCP/IP-based RPC service transport,
  1149. Xto which it returns a pointer.
  1150. XThe transport is associated with the socket
  1151. X.LW sock ,
  1152. Xwhich may be
  1153. X.LW RPC_ANYSOCK ,
  1154. Xin which case a new socket is created.
  1155. XIf the socket is not bound to a local TCP port, then this routine
  1156. Xbinds it to an arbitrary port.  Upon completion,
  1157. X.LW xprt->xp_sock
  1158. Xis the transport's socket number, and
  1159. X.LW xprt->xp_port
  1160. Xis the transport's port number.
  1161. XThis routine returns
  1162. X.LW NULL
  1163. Xif it fails.  Since TCP-based RPC uses buffered I/O,
  1164. Xusers may specify the size of the
  1165. X.LW send
  1166. Xand
  1167. X.LW receive
  1168. Xbuffers; values of zero choose suitable defaults.
  1169. X.SH
  1170. Xsvcudp_create()
  1171. X.LP
  1172. X.BS
  1173. X.LS
  1174. XSVCXPRT *
  1175. Xsvcudp_create(sock)
  1176. X    int sock;
  1177. X.Lf
  1178. X.BE
  1179. XThis routine creates a UDP/IP-based RPC service transport,
  1180. Xto which it returns a pointer.
  1181. XThe transport is associated with the socket
  1182. X.LW sock ,
  1183. Xwhich may be
  1184. X.LW RPC_ANYSOCK ,
  1185. Xin which case a new socket is created.
  1186. XIf the socket is not bound to a local UDP port, then this routine
  1187. Xbinds it to an arbitrary port.  Upon completion,
  1188. X.LW xprt->xp_sock
  1189. Xis the transport's socket number, and
  1190. X.LW xprt->xp_port
  1191. Xis the transport's port number.
  1192. XThis routine returns
  1193. X.LW NULL
  1194. Xif it fails.
  1195. XWarning: since UDP-based RPC messages can only hold up to 8 Kbytes
  1196. Xof encoded data, this transport cannot be used for procedures
  1197. Xthat take large arguments or return huge results.
  1198. X.SH
  1199. Xxdr_accepted_reply()
  1200. X.LP
  1201. X.BS
  1202. X.LS
  1203. Xxdr_accepted_reply(xdrs, ar)
  1204. X    XDR *xdrs;
  1205. X    struct accepted_reply *ar;
  1206. X.Lf
  1207. X.BE
  1208. XUsed for describing RPC messages, externally.
  1209. XThis routine is useful for users who wish to generate
  1210. XRPC-style messages without using the RPC package.
  1211. X.SH
  1212. Xxdr_array()
  1213. X.LP
  1214. X.BS
  1215. X.LS
  1216. Xxdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc)
  1217. X    XDR *xdrs;
  1218. X    char **arrp;
  1219. X    u_int *sizep, maxsize, elsize;
  1220. X    xdrproc_t elproc;
  1221. X.Lf
  1222. X.BE
  1223. XA filter primitive that translates between arrays
  1224. Xand their corresponding external representations.
  1225. XThe parameter
  1226. X.LW arrp
  1227. Xis the address of the pointer to the array, while
  1228. X.LW sizep
  1229. Xis the address of the element count of the array;
  1230. Xthis element count cannot exceed
  1231. X.LW maxsize .
  1232. XThe parameter
  1233. X.LW elsize
  1234. Xis the
  1235. X.LW sizeof()
  1236. Xeach of the array's elements, and
  1237. X.LW elproc
  1238. Xis an XDR filter that translates between
  1239. Xthe array elements' C form, and their external representation.
  1240. XThis routine returns one if it succeeds, zero otherwise.
  1241. X.SH
  1242. Xxdr_authunix_parms()
  1243. X.LP
  1244. X.BS
  1245. X.LS
  1246. Xxdr_authunix_parms(xdrs, aupp)
  1247. X    XDR *xdrs;
  1248. X    struct authunix_parms *aupp;
  1249. X.Lf
  1250. X.BE
  1251. XUsed for describing UNIX credentials, externally.
  1252. XThis routine is useful for users who wish to generate
  1253. Xthese credentials without using the RPC authentication package.
  1254. X.SH
  1255. Xxdr_bool()
  1256. X.LP
  1257. X.BS
  1258. X.LS
  1259. Xxdr_bool(xdrs, bp)
  1260. X    XDR *xdrs;
  1261. X    bool_t *bp;
  1262. X.Lf
  1263. X.BE
  1264. XA filter primitive that translates between booleans (C integers)
  1265. Xand their external representations.
  1266. XWhen encoding data, this filter produces values of either one or zero.
  1267. XThis routine returns one if it succeeds, zero otherwise.
  1268. X.SH
  1269. Xxdr_bytes()
  1270. X.LP
  1271. X.BS
  1272. X.LS
  1273. Xxdr_bytes(xdrs, sp, sizep, maxsize)
  1274. X    XDR *xdrs;
  1275. X    char **sp;
  1276. X    u_int *sizep, maxsize;
  1277. X.Lf
  1278. X.BE
  1279. XA filter primitive that translates between counted byte strings
  1280. Xand their external representations.
  1281. XThe parameter
  1282. X.LW sp
  1283. Xis the address of the string pointer.
  1284. XThe length of the string is located at address
  1285. X.LW sizep ;
  1286. Xstrings cannot be longer than
  1287. X.LW maxsize .
  1288. XThis routine returns one if it succeeds, zero otherwise.
  1289. X.SH
  1290. Xxdr_callhdr()
  1291. X.LP
  1292. X.BS
  1293. X.LS
  1294. Xvoid
  1295. Xxdr_callhdr(xdrs, chdr)
  1296. X    XDR *xdrs;
  1297. X    struct rpc_msg *chdr;
  1298. X.Lf
  1299. X.BE
  1300. XUsed for describing RPC messages, externally.
  1301. XThis routine is useful for users who wish to generate
  1302. XRPC-style messages without using the RPC package.
  1303. X.SH
  1304. Xxdr_callmsg()
  1305. X.LP
  1306. X.BS
  1307. X.LS
  1308. Xxdr_callmsg(xdrs, cmsg)
  1309. X    XDR *xdrs;
  1310. X    struct rpc_msg *cmsg;
  1311. X.Lf
  1312. X.BE
  1313. XUsed for describing RPC messages, externally.
  1314. XThis routine is useful for users who wish to generate
  1315. XRPC-style messages without using the RPC package.
  1316. X.SH
  1317. Xxdr_double()
  1318. X.LP
  1319. X.BS
  1320. X.LS
  1321. Xxdr_double(xdrs, dp)
  1322. X    XDR *xdrs;
  1323. X    double *dp;
  1324. X.Lf
  1325. X.BE
  1326. XA filter primitive that translates between C
  1327. X.LW double
  1328. Xprecision numbers and their external representations.
  1329. XThis routine returns one if it succeeds, zero otherwise.
  1330. X.SH
  1331. Xxdr_enum()
  1332. X.LP
  1333. X.BS
  1334. X.LS
  1335. Xxdr_enum(xdrs, ep)
  1336. X    XDR *xdrs;
  1337. X    enum_t *ep;
  1338. X.Lf
  1339. X.BE
  1340. XA filter primitive that translates between C
  1341. X.LW enum s
  1342. X(actually integers) and their external representations.
  1343. XThis routine returns one if it succeeds, zero otherwise.
  1344. X.SH
  1345. Xxdr_float()
  1346. X.LP
  1347. X.BS
  1348. X.LS
  1349. Xxdr_float(xdrs, fp)
  1350. X    XDR *xdrs;
  1351. X    float *fp;
  1352. X.Lf
  1353. X.BE
  1354. XA filter primitive that translates between C
  1355. X.LW float s
  1356. Xand their external representations.
  1357. XThis routine returns one if it succeeds, zero otherwise.
  1358. X.SH
  1359. Xxdr_inline()
  1360. X.LP
  1361. X.BS
  1362. X.LS
  1363. Xlong *
  1364. Xxdr_inline(xdrs, len)
  1365. X    XDR *xdrs;
  1366. X    int len;
  1367. X.Lf
  1368. X.BE
  1369. XA macro that invokes the in-line routine associated with the XDR stream,
  1370. X.LW xdrs .
  1371. XThe routine returns a pointer
  1372. Xto a contiguous piece of the stream's buffer;
  1373. X.LW len
  1374. Xis the byte length of the desired buffer.
  1375. XNote that pointer is cast to
  1376. X.LW "long *" .
  1377. XWarning:
  1378. X.LW xdr_inline()
  1379. Xmay return
  1380. X.LW NULL
  1381. X(0) if it cannot allocate a contiguous piece of a buffer.
  1382. XTherefore the behavior may vary among stream instances;
  1383. Xit exists for the sake of efficiency.
  1384. X.SH
  1385. Xxdr_int()
  1386. X.LP
  1387. X.BS
  1388. X.LS
  1389. Xxdr_int(xdrs, ip)
  1390. X    XDR *xdrs;
  1391. X    int *ip;
  1392. X.Lf
  1393. X.BE
  1394. XA filter primitive that translates between C integers
  1395. Xand their external representations.
  1396. XThis routine returns one if it succeeds, zero otherwise.
  1397. X.SH
  1398. Xxdr_long()
  1399. X.LP
  1400. X.BS
  1401. X.LS
  1402. Xxdr_long(xdrs, lp)
  1403. X    XDR *xdrs;
  1404. X    long *lp;
  1405. X.Lf
  1406. X.BE
  1407. XA filter primitive that translates between C
  1408. X.LW long
  1409. Xintegers and their external representations.
  1410. XThis routine returns one if it succeeds, zero otherwise.
  1411. X.SH
  1412. Xxdr_opaque()
  1413. X.LP
  1414. X.BS
  1415. X.LS
  1416. Xxdr_opaque(xdrs, cp, cnt)
  1417. X    XDR *xdrs;
  1418. X    char *cp;
  1419. X    u_int cnt;
  1420. X.Lf
  1421. X.BE
  1422. XA filter primitive that translates between fixed size opaque data
  1423. Xand its external representation.
  1424. XThe parameter
  1425. X.LW cp
  1426. Xis the address of the opaque object, and
  1427. X.LW cnt
  1428. Xis its size in bytes.
  1429. XThis routine returns one if it succeeds, zero otherwise.
  1430. X.SH
  1431. Xxdr_opaque_auth()
  1432. X.LP
  1433. X.BS
  1434. X.LS
  1435. Xxdr_opaque_auth(xdrs, ap)
  1436. X    XDR *xdrs;
  1437. X    struct opaque_auth *ap;
  1438. X.Lf
  1439. X.BE
  1440. XUsed for describing RPC messages, externally.
  1441. XThis routine is useful for users who wish to generate
  1442. XRPC-style messages without using the RPC package.
  1443. X.SH
  1444. Xxdr_pmap()
  1445. X.LP
  1446. X.BS
  1447. X.LS
  1448. Xxdr_pmap(xdrs, regs)
  1449. X    XDR *xdrs;
  1450. X    struct pmap *regs;
  1451. X.Lf
  1452. X.BE
  1453. XUsed for describing parameters to various
  1454. X.I portmap
  1455. Xprocedures, externally.
  1456. XThis routine is useful for users who wish to generate
  1457. Xthese parameters without using the
  1458. X.LW pmap
  1459. Xinterface.
  1460. X.SH
  1461. Xxdr_pmaplist()
  1462. X.LP
  1463. X.BS
  1464. X.LS
  1465. Xxdr_pmaplist(xdrs, rp)
  1466. X    XDR *xdrs;
  1467. X    struct pmaplist **rp;
  1468. X.Lf
  1469. X.BE
  1470. XUsed for describing a list of port mappings, externally.
  1471. XThis routine is useful for users who wish to generate
  1472. Xthese parameters without using the
  1473. X.LW pmap
  1474. Xinterface.
  1475. X.SH
  1476. Xxdr_reference()
  1477. X.LP
  1478. X.BS
  1479. X.LS
  1480. Xxdr_reference(xdrs, pp, size, proc)
  1481. X    XDR *xdrs;
  1482. X    char **pp;
  1483. X    u_int size;
  1484. X    xdrproc_t proc;
  1485. X.Lf
  1486. X.BE
  1487. XA primitive that provides pointer chasing within structures.
  1488. XThe parameter
  1489. X.LW pp
  1490. Xis the address of the pointer;
  1491. X.LW size
  1492. Xis the
  1493. X.LW sizeof()
  1494. Xthe structure that
  1495. X.LW *pp
  1496. Xpoints to; and
  1497. X.LW proc
  1498. Xis an XDR procedure that filters the structure
  1499. Xbetween its C form and its external representation.
  1500. XThis routine returns one if it succeeds, zero otherwise.
  1501. X.SH
  1502. Xxdr_rejected_reply()
  1503. X.LP
  1504. X.BS
  1505. X.LS
  1506. Xxdr_rejected_reply(xdrs, rr)
  1507. X    XDR *xdrs;
  1508. X    struct rejected_reply *rr;
  1509. X.Lf
  1510. X.BE
  1511. XUsed for describing RPC messages, externally.
  1512. XThis routine is useful for users who wish to generate
  1513. XRPC-style messages without using the RPC package.
  1514. X.SH
  1515. Xxdr_replymsg()
  1516. X.LP
  1517. X.BS
  1518. X.LS
  1519. Xxdr_replymsg(xdrs, rmsg)
  1520. X    XDR *xdrs;
  1521. X    struct rpc_msg *rmsg;
  1522. X.Lf
  1523. X.BE
  1524. XUsed for describing RPC messages, externally.
  1525. XThis routine is useful for users who wish to generate
  1526. XRPC style messages without using the RPC package.
  1527. X.SH
  1528. Xxdr_short()
  1529. X.LP
  1530. X.BS
  1531. X.LS
  1532. Xxdr_short(xdrs, sp)
  1533. X    XDR *xdrs;
  1534. X    short *sp;
  1535. X.Lf
  1536. X.BE
  1537. XA filter primitive that translates between C
  1538. X.LW short
  1539. Xintegers and their external representations.
  1540. XThis routine returns one if it succeeds, zero otherwise.
  1541. X.SH
  1542. Xxdr_string()
  1543. X.LP
  1544. X.BS
  1545. X.LS
  1546. Xxdr_string(xdrs, sp, maxsize)
  1547. X    XDR *xdrs;
  1548. X    char **sp;
  1549. X    u_int maxsize;
  1550. X.Lf
  1551. X.BE
  1552. XA filter primitive that translates between C strings and their
  1553. Xcorresponding external representations.
  1554. XStrings cannot be longer than
  1555. X.LW maxsize .
  1556. XNote that
  1557. X.LW sp
  1558. Xis the address of the string's pointer.
  1559. XThis routine returns one if it succeeds, zero otherwise.
  1560. X.SH
  1561. Xxdr_u_int()
  1562. X.LP
  1563. X.BS
  1564. X.LS
  1565. Xxdr_u_int(xdrs, up)
  1566. X    XDR *xdrs;
  1567. X    unsigned *up;
  1568. X.Lf
  1569. X.BE
  1570. XA filter primitive that translates between C
  1571. X.LW unsigned
  1572. Xintegers and their external representations.
  1573. XThis routine returns one if it succeeds, zero otherwise.
  1574. X.SH
  1575. Xxdr_u_long()
  1576. X.LP
  1577. X.BS
  1578. X.LS
  1579. Xxdr_u_long(xdrs, ulp)
  1580. X    XDR *xdrs;
  1581. X    unsigned long *ulp;
  1582. X.Lf
  1583. X.BE
  1584. XA filter primitive that translates between C
  1585. X.LW "unsigned long"
  1586. Xintegers and their external representations.
  1587. XThis routine returns one if it succeeds, zero otherwise.
  1588. X.SH
  1589. Xxdr_u_short()
  1590. X.LP
  1591. X.BS
  1592. X.LS
  1593. Xxdr_u_short(xdrs, usp)
  1594. X    XDR *xdrs;
  1595. X    unsigned short *usp;
  1596. X.Lf
  1597. X.BE
  1598. XA filter primitive that translates between C
  1599. X.LW "unsigned short"
  1600. Xintegers and their external representations.
  1601. XThis routine returns one if it succeeds, zero otherwise.
  1602. X.SH
  1603. Xxdr_union()
  1604. X.LP
  1605. X.BS
  1606. X.LS
  1607. Xxdr_union(xdrs, dscmp, unp, choices, dfault)
  1608. X    XDR *xdrs;
  1609. X    int *dscmp;
  1610. X    char *unp;
  1611. X    struct xdr_discrim *choices;
  1612. X    xdrproc_t dfault;
  1613. X.Lf
  1614. X.BE
  1615. XA filter primitive that translates between a discriminated C
  1616. X.LW union
  1617. Xand its corresponding external representation.  The parameter
  1618. X.LW dscmp
  1619. Xis the address of the union's discriminant, while
  1620. X.LW unp
  1621. Xin the address of the union.
  1622. XThis routine returns one if it succeeds, zero otherwise.
  1623. X.SH
  1624. Xxdr_void()
  1625. X.LP
  1626. X.BS
  1627. X.LS
  1628. Xxdr_void()
  1629. X.Lf
  1630. X.BE
  1631. XThis routine always returns one.
  1632. X.SH
  1633. Xxdr_wrapstring()
  1634. X.LP
  1635. X.BS
  1636. X.LS
  1637. Xxdr_wrapstring(xdrs, sp)
  1638. X    XDR *xdrs;
  1639. X    char **sp;
  1640. X.Lf
  1641. X.BE
  1642. XA primitive that calls
  1643. X.LW xdr_string(xdrs,sp,MAXUNSIGNED);
  1644. Xwhere
  1645. X.LW MAXUNSIGNED
  1646. Xis the maximum value of an unsigned integer.
  1647. XThis is handy because the RPC package passes
  1648. Xonly two parameters XDR routines, whereas
  1649. X.LW xdr_string() ,
  1650. Xone of the most frequently used primitives, requires three parameters.
  1651. XThis routine returns one if it succeeds, zero otherwise.
  1652. X.SH
  1653. Xxprt_register()
  1654. X.LP
  1655. X.BS
  1656. X.LS
  1657. Xvoid
  1658. Xxprt_register(xprt)
  1659. X    SVCXPRT *xprt;
  1660. X.Lf
  1661. X.BE
  1662. XAfter RPC service transport handles are created,
  1663. Xthey should register themselves with the RPC service package.
  1664. XThis routine modifies the global variable
  1665. X.LW svc_fds .
  1666. XService implementors usually don't need this routine.
  1667. X.SH
  1668. Xxprt_unregister()
  1669. X.LP
  1670. X.BS
  1671. X.LS
  1672. Xvoid
  1673. Xxprt_unregister(xprt)
  1674. X    SVCXPRT *xprt;
  1675. X.Lf
  1676. X.BE
  1677. XBefore an RPC service transport handle is destroyed,
  1678. Xit should unregister itself with the RPC service package.
  1679. XThis routine modifies the global variable
  1680. X.LW svc_fds .
  1681. XService implementors usually don't need this routine.
  1682. SHAR_EOF
  1683. if test 33027 -ne "`wc -c < 'rpc/doc/rpc.prog.p2'`"
  1684. then
  1685.     echo shar: "error transmitting 'rpc/doc/rpc.prog.p2'" '(should have been 33027 characters)'
  1686. fi
  1687. chmod 444 'rpc/doc/rpc.prog.p2'
  1688. fi
  1689. echo shar: "extracting 'rpc/doc/xdr.spec.p2'" '(16007 characters)'
  1690. if test -f 'rpc/doc/xdr.spec.p2'
  1691. then
  1692.     echo shar: "will not over-write existing file 'rpc/doc/xdr.spec.p2'"
  1693. else
  1694. sed 's/^X//' << \SHAR_EOF > 'rpc/doc/xdr.spec.p2'
  1695. X.LS
  1696. Xbool_t
  1697. Xxdr_wrap_list(xdrs, glp)
  1698. X    XDR *xdrs;
  1699. X    gnumbers_list *glp;
  1700. X{
  1701. X    return(xdr_reference(xdrs, glp, sizeof(struct gnnode),
  1702. X        xdr_gnnode));
  1703. X}
  1704. X.Lf
  1705. X.LS
  1706. Xstruct xdr_discrim choices[2] = {
  1707. X    /*
  1708. X     * called if another node needs (de)serializing
  1709. X     */
  1710. X    { TRUE, xdr_wrap_list },
  1711. X    /*
  1712. X     * called when no more nodes need (de)serializing
  1713. X     */
  1714. X    { FALSE, xdr_void }
  1715. X}
  1716. X.sp.5
  1717. Xbool_t
  1718. Xxdr_gnumbers_list(xdrs, glp)
  1719. X    XDR *xdrs;
  1720. X    gnumbers_list *glp;
  1721. X{
  1722. X    bool_t more_data;
  1723. X.sp.5
  1724. X    more_data = (*glp != (gnumbers_list)NULL);
  1725. X    return(xdr_union(xdrs, &more_data, glp, choices, NULL);
  1726. X}
  1727. X.Lf
  1728. XThe entry routine is
  1729. X.LW xdr_gnumbers_list() ;
  1730. Xits job is to translate between the boolean value
  1731. X.LW more_data
  1732. Xand the list pointer values.
  1733. XIf there is no more data, the
  1734. X.LW xdr_union()
  1735. Xprimitive calls
  1736. X.LW xdr_void()
  1737. Xand the recursion is terminated.
  1738. XOtherwise,
  1739. X.LW xdr_union()
  1740. Xcalls
  1741. X.LW xdr_wrap_list() ,
  1742. Xwhose job is to dereference the list pointers.
  1743. XThe
  1744. X.LW xdr_gnnode()
  1745. Xroutine actually (de)serializes data of the current node
  1746. Xof the linked list, and recursively calls
  1747. X.LW xdr_gnumbers_list()
  1748. Xto handle the remainder of the list.
  1749. X.LP
  1750. XYou should convince yourself that these routines
  1751. Xfunction correctly in all three directions
  1752. X.LW (XDR_ENCODE ,
  1753. X.LW XDR_DECODE ,
  1754. Xand
  1755. X.LW XDR_FREE)
  1756. Xfor linked lists of any length (including zero).
  1757. XNote that the boolean
  1758. X.LW more_data
  1759. Xis always initialized, but in the
  1760. X.LW XDR_DECODE
  1761. Xcase it is overwritten by an externally generated value.
  1762. XAlso note that the value of the
  1763. X.LW bool_t
  1764. Xis lost in the stack.
  1765. XThe essence of the value is reflected in the list's pointers.
  1766. X.LP
  1767. XThe unfortunate side effect of (de)serializing a list
  1768. Xwith these routines is that the C stack grows linearly
  1769. Xwith respect to the number of nodes in the list.
  1770. XThis is due to the recursion.
  1771. XThe routines are also hard to 
  1772. Xcode (and understand) due to the number and nature of primitives involved
  1773. X(such as
  1774. X.LW xdr_reference ,
  1775. X.LW xdr_union ,
  1776. Xand
  1777. X.LW xdr_void ).
  1778. X.LP
  1779. XThe following routine collapses the recursive routines.
  1780. XIt also has other optimizations that are discussed below.
  1781. X.LS
  1782. Xbool_t
  1783. Xxdr_gnumbers_list(xdrs, glp)
  1784. X    XDR *xdrs;
  1785. X    gnumbers_list *glp;
  1786. X{
  1787. X    bool_t more_data;
  1788. X.sp.5
  1789. X    while (TRUE) {
  1790. X        more_data = (*glp != (gnumbers_list)NULL);
  1791. X        if (!xdr_bool(xdrs, &more_data))
  1792. X            return(FALSE);
  1793. X        if (!more_data)
  1794. X            return(TRUE);  /* we are done */
  1795. X        if (!xdr_reference(xdrs, glp, sizeof(struct gnnode),
  1796. X            xdr_gnumbers))
  1797. X            return(FALSE);
  1798. X        glp = &((*glp)->nxt); 
  1799. X    }
  1800. X}
  1801. X.Lf
  1802. XThe claim is that this one routine is easier to code and understand than the
  1803. Xthree recursive routines above.
  1804. X(It is also buggy, as discussed below.)
  1805. XThe parameter
  1806. X.LW glp
  1807. Xis treated as the address of the pointer 
  1808. Xto the head of the
  1809. Xremainder of the list to be (de)serialized.
  1810. XThus,
  1811. X.LW glp
  1812. Xis set to the
  1813. Xaddress of the current node's
  1814. X.LW nxt
  1815. Xfield at the end of the while loop.
  1816. XThe discriminated union is implemented in-line; the variable
  1817. X.LW more_data
  1818. Xhas the same use in this routine as in the routines above.
  1819. XIts value is
  1820. Xrecomputed and re-(de)serialized each iteration of the loop.
  1821. XSince
  1822. X.LW *glp
  1823. Xis a pointer to a node, the pointer is dereferenced using 
  1824. X.LW xdr_reference() .
  1825. XNote that the third parameter is truly the size of a node
  1826. X(data values plus
  1827. X.LW nxt
  1828. Xpointer), while
  1829. X.LW xdr_gnumbers()
  1830. Xonly (de)serializes the data values.
  1831. XWe can get away with this tricky optimization only because the
  1832. X.LW nxt
  1833. Xdata comes after all legitimate external data.
  1834. X.LP
  1835. XThe routine is buggy in the
  1836. X.LW XDR_FREE
  1837. Xcase.  The bug is that
  1838. X.LW xdr_reference()
  1839. Xwill free the node
  1840. X.LW *glp .
  1841. XUpon return the assignment
  1842. X.LW "glp = &((*glp)->nxt)"
  1843. Xcannot be guaranteed to work since
  1844. X.LW *glp
  1845. Xis no longer a legitimate node.
  1846. XThe following is a rewrite that works in all cases.
  1847. XThe hard part is to avoid dereferencing a pointer
  1848. Xwhich has not been initialized or which has been freed.
  1849. X.LS
  1850. Xbool_t
  1851. Xxdr_gnumbers_list(xdrs, glp)
  1852. X    XDR *xdrs;
  1853. X    gnumbers_list *glp;
  1854. X{
  1855. X    bool_t more_data;
  1856. X    bool_t freeing;
  1857. X    gnumbers_list *next;  /* the next value of glp */
  1858. X.sp.5
  1859. X    freeing = (xdrs->x_op == XDR_FREE);
  1860. X    while (TRUE) {
  1861. X        more_data = (*glp != (gnumbers_list)NULL);
  1862. X        if (!xdr_bool(xdrs, &more_data))
  1863. X            return(FALSE);
  1864. X        if (!more_data)
  1865. X            return(TRUE);  /* we are done */
  1866. X        if (freeing)
  1867. X            next = &((*glp)->nxt);
  1868. X        if (!xdr_reference(xdrs, glp, sizeof(struct gnnode),
  1869. X            xdr_gnumbers))
  1870. X            return(FALSE);
  1871. X        glp = (freeing) ? next : &((*glp)->nxt);
  1872. X    }
  1873. X}
  1874. X.Lf
  1875. XNote that this is the first example in this document
  1876. Xthat actually inspects the direction of the operation
  1877. X.LW xdrs->x_op ). (
  1878. XThe claim is that the correct iterative implementation is still 
  1879. Xeasier to understand or code than the recursive implementation.
  1880. XIt is certainly more efficient with respect to C stack requirements.
  1881. X.NH 2
  1882. XThe Record Marking Standard
  1883. X.LP
  1884. XA record is composed of one or more record fragments.
  1885. XA record fragment is a four-byte header followed by
  1886. X$ 0 ~ "\fRto\fP" ~ {2 sup 31} - 1$ bytes of fragment data.
  1887. XThe bytes encode an unsigned binary number;
  1888. Xas with XDR integers, the byte order is from highest to lowest.
  1889. XThe number encodes two values \(em
  1890. Xa boolean that indicates whether the fragment is the last fragment
  1891. Xof the record (bit value 1 implies the fragment is the last fragment),
  1892. Xand a 31-bit unsigned binary value
  1893. Xwhich is the length in bytes of the fragment's data.
  1894. XThe boolean value is the high-order bit of the
  1895. Xheader; the length is the 31 low-order bits.
  1896. X.LP
  1897. X(Note that this record specification is
  1898. X.I not
  1899. Xin XDR standard form
  1900. Xand cannot be implemented using XDR primitives!)
  1901. X.\"
  1902. X.bp
  1903. X.SH
  1904. XAppendix A -- Synopsis of XDR Routines
  1905. X.LP
  1906. X.LW xdr_array()
  1907. X.LS
  1908. Xxdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc)
  1909. X    XDR *xdrs;
  1910. X    char **arrp;
  1911. X    u_int *sizep, maxsize, elsize;
  1912. X    xdrproc_t elproc;
  1913. X.Lf
  1914. XA filter primitive that translates between arrays
  1915. Xand their corresponding external representations.
  1916. XThe parameter
  1917. X.LW arrp
  1918. Xis the address of the pointer to the array, while
  1919. X.LW sizep
  1920. Xis the address of the element count of the array;
  1921. Xthis element count cannot exceed
  1922. X.LW maxsize .
  1923. XThe parameter
  1924. X.LW elsize
  1925. Xis the
  1926. X.LW sizeof()
  1927. Xeach of the array's elements, and
  1928. X.LW elproc
  1929. Xis an XDR filter that translates between
  1930. Xthe array elements' C form, and their external representation.  
  1931. XThis routine returns one if it succeeds, zero otherwise.
  1932. X.LP
  1933. X.LW xdr_bool()
  1934. X.LS
  1935. Xxdr_bool(xdrs, bp)
  1936. X    XDR *xdrs;
  1937. X    bool_t *bp;
  1938. X.Lf
  1939. XA filter primitive that translates between booleans (C integers)
  1940. Xand their external representations.
  1941. XWhen encoding data, this filter produces values of either one or zero.
  1942. XThis routine returns one if it succeeds, zero otherwise.
  1943. X.LP
  1944. X.LW xdr_bytes()
  1945. X.LS
  1946. Xxdr_bytes(xdrs, sp, sizep, maxsize)
  1947. X    XDR *xdrs;
  1948. X    char **sp;
  1949. X    u_int *sizep, maxsize;
  1950. X.Lf
  1951. XA filter primitive that translates between counted byte strings
  1952. Xand their external representations.
  1953. XThe parameter
  1954. X.LW sp
  1955. Xis the address of the string pointer.
  1956. XThe length of the string is located at address
  1957. X.LW sizep ;
  1958. Xstrings cannot be longer than
  1959. X.LW maxsize .
  1960. XThis routine returns one if it succeeds, zero otherwise.
  1961. X.LP
  1962. X.LW xdr_destroy()
  1963. X.LS
  1964. Xvoid
  1965. Xxdr_destroy(xdrs)
  1966. X    XDR *xdrs;
  1967. X.Lf
  1968. XA macro that invokes the destroy routine
  1969. Xassociated with the XDR stream,
  1970. X.LW xdrs .
  1971. XDestruction usually involves freeing private data structures
  1972. Xassociated with the stream.  Using
  1973. X.LW xdrs
  1974. Xafter invoking
  1975. X.LW xdr_destroy()
  1976. Xis undefined.
  1977. X.LP
  1978. X.LW xdr_double()
  1979. X.LS
  1980. Xxdr_double(xdrs, dp)
  1981. X    XDR *xdrs;
  1982. X    double *dp;
  1983. X.Lf
  1984. XA filter primitive that translates between C
  1985. X.LW double
  1986. Xprecision numbers and their external representations.
  1987. XThis routine returns one if it succeeds, zero otherwise.
  1988. X.LP
  1989. X.LW xdr_enum()
  1990. X.LS
  1991. Xxdr_enum(xdrs, ep)
  1992. X    XDR *xdrs;
  1993. X    enum_t *ep;
  1994. X.Lf
  1995. XA filter primitive that translates between C
  1996. X.LW enum s
  1997. X(actually integers) and their external representations.
  1998. XThis routine returns one if it succeeds, zero otherwise.
  1999. X.LP
  2000. X.LW xdr_float()
  2001. X.LS
  2002. Xxdr_float(xdrs, fp)
  2003. X    XDR *xdrs;
  2004. X    float *fp;
  2005. X.Lf
  2006. XA filter primitive that translates between C
  2007. X.LW float s
  2008. Xand their external representations.
  2009. XThis routine returns one if it succeeds, zero otherwise.
  2010. X.LP
  2011. X.LW xdr_getpos()
  2012. X.LS
  2013. Xu_int
  2014. Xxdr_getpos(xdrs)
  2015. X    XDR *xdrs;
  2016. X.Lf
  2017. XA macro that invokes the get-position routine
  2018. Xassociated with the XDR stream,
  2019. X.LW xdrs .
  2020. XThe routine returns an unsigned integer,
  2021. Xwhich indicates the position of the XDR byte stream.
  2022. XA desirable feature of XDR streams
  2023. Xis that simple arithmetic works with this number,
  2024. Xalthough the XDR stream instances need not guarantee this.
  2025. X.LP
  2026. X.LW xdr_inline()
  2027. X.LS
  2028. Xlong *
  2029. Xxdr_inline(xdrs, len)
  2030. X    XDR *xdrs;
  2031. X    int len;
  2032. X.Lf
  2033. XA macro that invokes the in-line routine associated with the XDR stream,
  2034. X.LW xdrs .
  2035. XThe routine returns a pointer
  2036. Xto a contiguous piece of the stream's buffer;
  2037. X.LW len
  2038. Xis the byte length of the desired buffer.
  2039. XNote that the pointer is cast to
  2040. X.LW "long *" .
  2041. XWarning:
  2042. X.LW xdr_inline()
  2043. Xmay return 
  2044. X.LW NULL
  2045. Xif it cannot allocate a contiguous piece of a buffer.
  2046. XTherefore the behavior may vary among stream instances;
  2047. Xit exists for the sake of efficiency.
  2048. X.LP
  2049. X.LW xdr_int()
  2050. X.LS
  2051. Xxdr_int(xdrs, ip)
  2052. X    XDR *xdrs;
  2053. X    int *ip;
  2054. X.Lf
  2055. XA filter primitive that translates between C integers
  2056. Xand their external representations.
  2057. XThis routine returns one if it succeeds, zero otherwise.
  2058. X.LP
  2059. X.LW xdr_long()
  2060. X.LS
  2061. Xxdr_long(xdrs, lp)
  2062. X    XDR *xdrs;
  2063. X    long *lp;
  2064. X.Lf
  2065. XA filter primitive that translates between C
  2066. X.LW long
  2067. Xintegers and their external representations.
  2068. XThis routine returns one if it succeeds, zero otherwise.
  2069. X.LP
  2070. X.LW xdr_opaque()
  2071. X.LS
  2072. Xxdr_opaque(xdrs, cp, cnt)
  2073. X    XDR *xdrs;
  2074. X    char *cp;
  2075. X    u_int cnt;
  2076. X.Lf
  2077. XA filter primitive that translates between fixed size opaque data
  2078. Xand its external representation.
  2079. XThe parameter
  2080. X.LW cp
  2081. Xis the address of the opaque object, and
  2082. X.LW cnt
  2083. Xis its size in bytes.
  2084. XThis routine returns one if it succeeds, zero otherwise.
  2085. X.LP
  2086. X.LW xdr_reference()
  2087. X.LS
  2088. Xxdr_reference(xdrs, pp, size, proc)
  2089. X    XDR *xdrs;
  2090. X    char **pp;
  2091. X    u_int size;
  2092. X    xdrproc_t proc;
  2093. X.Lf
  2094. XA primitive that provides pointer chasing within structures.
  2095. XThe parameter
  2096. X.LW pp
  2097. Xis the address of the pointer;
  2098. X.LW size
  2099. Xis the
  2100. X.LW sizeof()
  2101. Xthe structure that
  2102. X.LW *pp
  2103. Xpoints to; and
  2104. X.LW proc
  2105. Xis an XDR procedure that filters the structure
  2106. Xbetween its C form and its external representation.
  2107. XThis routine returns one if it succeeds, zero otherwise.
  2108. X.LP
  2109. X.LW xdr_setpos()
  2110. X.LS
  2111. Xxdr_setpos(xdrs, pos)
  2112. X    XDR *xdrs;
  2113. X    u_int pos;
  2114. X.Lf
  2115. XA macro that invokes the set position routine associated with the XDR stream
  2116. X.LW xdrs .
  2117. XThe parameter
  2118. X.LW pos
  2119. Xis a position value obtained from
  2120. X.LW xdr_getpos() .
  2121. XThis routine returns one if the XDR stream could be repositioned,
  2122. Xand zero otherwise.
  2123. XWarning: it is difficult to reposition some types of XDR streams,
  2124. Xso this routine may fail with one type of stream and succeed with another. 
  2125. X.LP
  2126. X.LW xdr_short()
  2127. X.LS
  2128. Xxdr_short(xdrs, sp)
  2129. X    XDR *xdrs;
  2130. X    short *sp;
  2131. X.Lf
  2132. XA filter primitive that translates between C
  2133. X.LW short
  2134. Xintegers and their external representations.
  2135. XThis routine returns one if it succeeds, zero otherwise.
  2136. X.LP
  2137. X.LW xdr_string()
  2138. X.LS
  2139. Xxdr_string(xdrs, sp, maxsize)
  2140. X    XDR *xdrs;
  2141. X    char **sp;
  2142. X    u_int maxsize;
  2143. X.Lf
  2144. XA filter primitive that translates between C strings and their
  2145. Xcorresponding external representations.
  2146. XStrings cannot cannot be longer than
  2147. X.LW maxsize .
  2148. XNote that
  2149. X.LW sp
  2150. Xis the address of the string's pointer.
  2151. XThis routine returns one if it succeeds, zero otherwise.
  2152. X.LP
  2153. X.LW xdr_u_int()
  2154. X.LS
  2155. Xxdr_u_int(xdrs, up)
  2156. X    XDR *xdrs;
  2157. X    unsigned *up;
  2158. X.Lf
  2159. XA filter primitive that translates between C
  2160. X.LW unsigned
  2161. Xintegers and their external representations.
  2162. XThis routine returns one if it succeeds, zero otherwise.
  2163. X.LP
  2164. X.LW xdr_u_long()
  2165. X.LS
  2166. Xxdr_u_long(xdrs, ulp)
  2167. X    XDR *xdrs;
  2168. X    unsigned long *ulp;
  2169. X.Lf
  2170. XA filter primitive that translates between C
  2171. X.LW "unsigned long"
  2172. Xintegers and their external representations.
  2173. XThis routine returns one if it succeeds, zero otherwise.
  2174. X.LP
  2175. X.LW xdr_u_short()
  2176. X.LS
  2177. Xxdr_u_short(xdrs, usp)
  2178. X    XDR *xdrs;
  2179. X    unsigned short *usp;
  2180. X.Lf
  2181. XA filter primitive that translates between C
  2182. X.LW "unsigned short"
  2183. Xintegers and their external representations.
  2184. XThis routine returns one if it succeeds, zero otherwise.
  2185. X.br
  2186. X.ne 2i
  2187. X.LW xdr_union()
  2188. X.LS
  2189. Xxdr_union(xdrs, dscmp, unp, choices, dfault)
  2190. X    XDR *xdrs;
  2191. X    int *dscmp;
  2192. X    char *unp;
  2193. X    struct xdr_discrim *choices;
  2194. X    xdrproc_t dfault;
  2195. X.Lf
  2196. XA filter primitive that translates between a discriminated C
  2197. X.LW union
  2198. Xand its corresponding external representation.  The parameter 
  2199. X.LW dscmp
  2200. Xis the address of the union's discriminant, while
  2201. X.Lunp
  2202. Xin the address of the union.
  2203. XThis routine returns one if it succeeds, zero otherwise.
  2204. X.LP
  2205. X.LW xdr_void()
  2206. X.LS
  2207. Xxdr_void()
  2208. X.Lf
  2209. XThis routine always returns one.
  2210. XIt may be passed to RPC routines that require a function parameter,
  2211. Xwhere nothing is to be done.
  2212. X.LP
  2213. X.LW xdr_wrapstring()
  2214. X.LS
  2215. Xxdr_wrapstring(xdrs, sp)
  2216. X    XDR *xdrs;
  2217. X    char **sp;
  2218. X.Lf
  2219. XA primitive that calls
  2220. X.LW xdr_string(xdrs,sp,MAXUNSIGNED);
  2221. Xwhere
  2222. X.LW MAXUNSIGNED
  2223. Xis the maximum value of an unsigned integer.
  2224. XThis is handy because the RPC package passes
  2225. Xonly two parameters XDR routines, whereas
  2226. X.LW xdr_string() ,
  2227. Xone of the most frequently used primitives, requires three parameters.
  2228. XThis routine returns one if it succeeds, zero otherwise.
  2229. X.LP
  2230. X.LW xdrmem_create()
  2231. X.LS
  2232. Xvoid
  2233. Xxdrmem_create(xdrs, addr, size, op)
  2234. X    XDR *xdrs;
  2235. X    char *addr;
  2236. X    u_int size;
  2237. X    enum xdr_op op;
  2238. X.Lf
  2239. XThis routine initializes the XDR stream object pointed to by
  2240. X.LW xdrs .
  2241. XThe stream's data is written to, or read from,
  2242. Xa chunk of memory at location
  2243. X.LW addr
  2244. Xwhose length is no more than
  2245. X.LW size
  2246. Xbytes long.  The
  2247. X.LW op
  2248. Xdetermines the direction of the XDR stream
  2249. X(either
  2250. X.LW XDR_ENCODE ,
  2251. X.LW XDR_DECODE ,
  2252. Xor
  2253. X.LW XDR_FREE ).
  2254. X.LP
  2255. X.LW xdrrec_create()
  2256. X.LS
  2257. Xvoid
  2258. Xxdrrec_create(xdrs,
  2259. X  sendsize, recvsize, handle, readit, writeit)
  2260. X    XDR *xdrs;
  2261. X    u_int sendsize, recvsize;
  2262. X    char *handle;
  2263. X    int (*readit)(), (*writeit)();
  2264. X.Lf
  2265. XThis routine initializes the XDR stream object pointed to by
  2266. X.LW xdrs .
  2267. XThe stream's data is written to a buffer of size
  2268. X.LW sendsize ;
  2269. Xa value of zero indicates the system should use a suitable default.
  2270. XThe stream's data is read from a buffer of size
  2271. X.LW recvsize ;
  2272. Xit too can be set to a suitable default by passing a zero value.
  2273. XWhen a stream's output buffer is full,
  2274. X.LW writeit()
  2275. Xis called.  Similarly, when a stream's input buffer is empty,
  2276. X.LW readit()
  2277. Xis called.  The behavior of these two routines
  2278. Xis similar to the
  2279. X.UX
  2280. Xsystem calls
  2281. X.LW read
  2282. Xand
  2283. X.LW write ,
  2284. Xexcept that
  2285. X.LW handle
  2286. Xis passed to the former routines as the first parameter.
  2287. XNote that the XDR stream's
  2288. X.LW op
  2289. Xfield must be set by the caller.
  2290. XWarning: this XDR stream implements an intermediate record stream.
  2291. XTherefore there are additional bytes in the stream
  2292. Xto provide record boundary information.
  2293. X.LP
  2294. X.LW xdrrec_endofrecord()
  2295. X.LS
  2296. Xxdrrec_endofrecord(xdrs, sendnow)
  2297. X    XDR *xdrs;
  2298. X    int sendnow;
  2299. X.Lf
  2300. XThis routine can be invoked only on streams created by
  2301. X.LW xdrrec_create() .
  2302. XThe data in the output buffer is marked as a completed record,
  2303. Xand the output buffer is optionally written out if
  2304. X.LW sendnow
  2305. Xis non-zero.  This routine returns one if it succeeds, zero otherwise.
  2306. X.LP
  2307. X.LW xdrrec_eof()
  2308. X.LS
  2309. Xxdrrec_eof(xdrs)
  2310. X    XDR *xdrs;
  2311. X    int empty;
  2312. X.Lf
  2313. XThis routine can be invoked only on streams created by
  2314. X.LW xdrrec_create() .
  2315. XAfter consuming the rest of the current record in the stream,
  2316. Xthis routine returns one if the stream has no more input, zero otherwise.
  2317. X.LP
  2318. X.LW xdrrec_skiprecord()
  2319. X.LS
  2320. Xxdrrec_skiprecord(xdrs)
  2321. X    XDR *xdrs;
  2322. X.Lf
  2323. XThis routine can be invoked only on streams created by
  2324. X.LW xdrrec_create() .
  2325. XIt tells the XDR implementation that the rest of the current record
  2326. Xin the stream's input buffer should be discarded.
  2327. XThis routine returns one if it succeeds, zero otherwise.
  2328. X.LP
  2329. X.LW xdrstdio_create()
  2330. X.LS
  2331. Xvoid
  2332. Xxdrstdio_create(xdrs, file, op)
  2333. X    XDR *xdrs;
  2334. X    FILE *file;
  2335. X    enum xdr_op op;
  2336. X.Lf
  2337. XThis routine initializes the XDR stream object pointed to by
  2338. X.LW xdrs .
  2339. XThe XDR stream data is written to, or read from, the Standard I/O stream
  2340. X.LW file .
  2341. XThe parameter
  2342. X.LW op
  2343. Xdetermines the direction of the XDR stream (either
  2344. X.LW XDR_ENCODE ,
  2345. X.LW XDR_DECODE ,
  2346. Xor
  2347. X.LW XDR_FREE ).
  2348. XWarning: the destroy routine associated with such XDR streams calls
  2349. X.LW fflush()
  2350. Xon the
  2351. X.LW file
  2352. Xstream, but never
  2353. X.LW fclose() . 
  2354. SHAR_EOF
  2355. if test 16007 -ne "`wc -c < 'rpc/doc/xdr.spec.p2'`"
  2356. then
  2357.     echo shar: "error transmitting 'rpc/doc/xdr.spec.p2'" '(should have been 16007 characters)'
  2358. fi
  2359. chmod 444 'rpc/doc/xdr.spec.p2'
  2360. fi
  2361. exit 0
  2362. #    End of shell archive
  2363.